<template>
	<view class="page">
			<view  v-if="queueList.length>0" >
				<view class="margin-bottom" v-for="(item,index) in queueList" :key='index'>
					<view class="cu-bar bg-white solid-bottom">
						<view class="action">
							<text class="content-label text-bold">车次单号：</text>
							<text>{{item.TruckTransportNO}}</text><text style="padding: 0 3px;"> / </text>
							<text class="text-bold">{{item.LicensePlateNO}}</text>
						</view>
						<view class="action" @click="bindCargoCar(index)">
							<text class="lg text-blue cuIcon-link"></text>
						</view>
					</view>
					<view class="cu-list menu sm-border" v-for="(item1,index1) in item.DetailList" :key="index1">
						<view  class="cu-item arrow cus-item" >
							<view class="mark-type">
								<text class="text-white mark-type-item" style="background-color: #FAAD14;" v-if="item1.IsUrgent===1" >急</text>
								<!-- <text class="text-white mark-type-item"  style="background-color: #52C41A;" v-else >缓</text> -->
							</view>
							<view class="">
								<text class="">卸货仓：{{item1.WarehouseNO}}</text>
							</view>
							<view class="text-red">{{state[item1.QueueStatus]}}</view>
							<view class="action">
								<!-- <button class="cu-btn round bg-green shadow " style="background-color: #0081FF;width: 86px;"
								 @click="apply(index,index1,'apply')"  v-if="item1.QueueStatus==0">预约</button> -->
							 <button class="cu-btn round bg-green shadow " style="background-color: #0081FF;"
								@click="scan(index,index1)"  v-if="item1.QueueStatus==4">重新激活</button>
								 <text @click="apply(index,index1)" :data-id="item1.id" v-else>{{item1.QueueUpNO}}</text>
							</view>
						</view>
					</view>
			</view>
			
			
			
		</view>
		<view class="haveNOList" v-else><view class="haveNOList-view">暂无数据</view></view>
		
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isOrder:false,
				session:'',
				queueList:[],
				TruckTransportNO:'',
				LicensePlateNO:'',
				TruckTransportID:'',
				state:['未排队','进行中','已完成','等待中','已挂起'],
			}
		},
		onLoad(){
			
		},
		onShow() {
			this.getSummaryList()
		},
		methods: {
			getSummaryList(){
				uni.showLoading({
				    title: '加载中'
				});
				this.session=uni.getStorageSync('session')
				this.$store.dispatch('uni/QueueSummaryList',{openid:this.session.openid})
				 .then((res)=>{
					this.queueList=res.Data
					uni.hideLoading()
				}).catch(()=>uni.hideLoading())
			},
			apply(index,index1,type){
				console.log('?????',index,index1,type)
				
				const params={}
				params.id=this.queueList[index].TruckTransportNO
				params.no=this.queueList[index].LicensePlateNO
				params.quno=this.queueList[index].DetailList[index1].QueueUpNO
				params.whno=this.queueList[index].DetailList[index1].WarehouseNO
				params.status=this.queueList[index].DetailList[index1].QueueStatus
				params.queneUpId=this.queueList[index].DetailList[index1].QueueUpID
				let IsUrgent=this.queueList[index].DetailList[index1].IsUrgent
				uni.navigateTo({
					url:`/pages/lineUp/applyLineUp?id=${params.id}&no=${params.no}&quno=${params.quno}&whno=${params.whno}&status=${params.status}&type=${type}&IsUrgent=${IsUrgent}&queneUpId=${params.queneUpId}`
				})
			},
			scan(index,index1){
				let params={}
				params.openid=this.session.openid
				params.queueUpNO=this.queueList[index].DetailList[index1].QueueUpNO
				params.IsUrgent=this.queueList[index].DetailList[index1].IsUrgent
				// params.query=true
				uni.scanCode({
					success: res => {
						 if( res.result){
							 params.warehouseNO=res.result
							 console.log('params',params)
							this.$store.dispatch('uni/ScanPierQR',params).then(v=>{
								console.log('88888')
								const {Code,Message}=v
								console.log(typeof Code,)
								if(v.Code===0){
									showModal({
										title:'请求成功',
										content:'重新激活成功'
									})
									this.getSummaryList()
								}
							}).catch((res)=>{
								uni.showToast({
									title:'请求失败',
									icon:'none',
								})
							})
						 }else{
							 uni.showToast({
								 title:'请扫描正确的二维码'
							 })
						 }
					}
				});
			},
			bindCargoCar(index){
				this.TruckTransportNO=this.queueList[index].TruckTransportNO
				this.LicensePlateNO=this.queueList[index].LicensePlateNO
				this.TruckTransportID=this.queueList[index].TruckTransportID
				uni.navigateTo({
					url:`/pages/lineUp/bindGoodsCar?id=${this.TruckTransportNO}&&no=${this.LicensePlateNO}&&ttid=${this.TruckTransportID}`
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.cus-item{
		display: flex;
		justify-content: space-around;
		align-items: center;
	}
	.haveNOList{
		display: flex;
		text-align: center;
		
		&-view {
			top: 300upx;
			width: 100%;
			height: 300upx;
			line-height: 300upx;
			font-size: 16px;
			
		}
	}
	.mark-type{
		height: 32px;
		width: 32px;
		font-weight: bolder;
		&-item{
			display: inline-block;
			width: 100%;
			height: 100%;
			border-radius: 50px;
			text-align: center;
			line-height: 32px;
		}
	}
</style>
